package mvc.spring.controller.commandObject;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.AssertTrue;

public class UserRegistationCommand {

	@NotEmpty
    @NotNull
    @Size(min = 1, max = 20)
	private String userNickName;
	
	@NotEmpty
    @NotNull
    @Size(min = 1, max = 20)
	private String userPassword;
	
	@NotEmpty
    @NotNull
    @Size(min = 1, max = 20)
	private String reUserPassword;
		
	
    @NotNull    
	@Min(value = 0)
	@Max(value = 1)
	private Integer userGender;
	
	
    @NotNull
	private Integer userAge;
	
    public UserRegistationCommand() { }
    
	@AssertTrue(message="password and confirmation should be equal")
    public boolean isPasswordValid(){
        if (userPassword == null) {
               return false;
        } else {
             return userPassword.equals(reUserPassword);
        }
    }
			
	public String getUserNickName() {
		return userNickName;
	}

	public void setUserNickName(String userNickName) {
		this.userNickName = userNickName;
	}

	public Integer getUserGender() {
		return userGender;
	}

	public void setUserGender(Integer userGender) {
		this.userGender = userGender;
	}

	public Integer getUserAge() {
		return userAge;
	}

	public void setUserAge(Integer userAge) {
		this.userAge = userAge;
	}
	
	public String getUserPassword() {
		return userPassword;
	}

	public void setUserPassword(String userPassword) {
		this.userPassword = userPassword;
	}

	public String getReUserPassword() {
		return reUserPassword;
	}


	public void setReUserPassword(String reUserPassword) {
		this.reUserPassword = reUserPassword;
	}
	
}
